/**
 * Created whit IntelliJ IDEA.
 * Description：
 * User：ZHONGCHEN
 * Date:2022-03-07
 * Time:19:36
 */
public class TestDemo {
    //10进制转换7进制
    //return Integer.toString(num,7);
    public static String convertToBase7(int num) {
        int sum = 0;
        boolean flag = false;
        if (num < 0) {
            flag = true;
            num *= -1;
        }
        StringBuilder ans = new StringBuilder();
       do {
           ans.append(num%7);
           num /= 7;
       }while (num != 0);
       ans.reverse();
       return flag?"-"+ans.toString():ans.toString();
    }

    public static void main(String[] args) {
        System.out.println(convertToBase7(-7));
    }
}
